﻿Option Strict On
Option Explicit On
Option Infer On

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Xml.Linq
Imports GenDotNet.Task.Common
Imports GenDotNet.Model.Common
Imports <xmlns:orm="http://kadgen.com/KADORM.xsd">
Imports <xmlns:kd="http://kadgen.com/Special.xsd">
Imports <xmlns:s="http://kadgen.com/Select.xsd">

Namespace GenInputMetadata

   Public MustInherit Class BaseData
      Implements IBaseData

      Private mElement As XElement
      Private mRootData As RootData

      Protected Sub New(ByVal rootData As RootData, ByVal element As XElement)
         Me.mRootData = rootData
         Me.mElement = element
      End Sub

      Protected Friend ReadOnly Property Element() As XElement
         Get
            Return mElement
         End Get
      End Property

      Protected Friend ReadOnly Property RootData() As RootData
         Get
            Return mRootData
         End Get
      End Property

      Public ReadOnly Property GuessesMade() As Boolean Implements Model.Common.IBaseData.GuessesMade
         Get
            Return False
         End Get
      End Property

      Public Function GetCustomData(ByVal name As String) As String Implements Model.Common.IBaseData.GetCustomData
         Dim attr = mElement.Attribute(name)
         If attr Is Nothing Then
            Return Nothing
         End If
         Return attr.Value
      End Function

      'Protected Shared Sub LoadData(ByVal element As XElement)
      '   mObjects = New Dictionary(Of String, ObjectData)
      '   Dim root = element.Document.Root
      '   For Each objectElement In root...<orm:Object>
      '      mObjects.Add(objectElement.@Name, ObjectData.Load(objectElement, False))
      '   Next
      'End Sub


      'Protected Shared ReadOnly Property Objects() As Dictionary(Of String, ObjectData)
      '   Get
      '      Return mObjects
      '   End Get
      'End Property

   End Class
End Namespace
